package com.yl.pattern.behavioralmodel.memento.black_box;



/**
 * @Author 小羊
 * @Date 1/11/2024下午 5:20
 * @ClassName Client
 * @Description Client
 */
public class Client {
    public static void main(String[] args) {
        System.out.println("----------大战boss前-----------");
        GameRole gameRole = new GameRole();
        gameRole.initState();
        gameRole.stateDisplay();
        //备份
        RoleStateCaretaker roleStateCaretaker = new RoleStateCaretaker();
        roleStateCaretaker.setMemento(gameRole.saveState());
        System.out.println("----------大战boss后-----------");
        gameRole.fight();
        gameRole.stateDisplay();
        System.out.println("----------恢复之前的状态-----------");
        gameRole.recoverState(roleStateCaretaker.getMemento());
        gameRole.stateDisplay();
    }
}
